package com.xiaolun.other;

import java.io.*;

public class Demo07 {
	public static void main(String[] args) {
		fileReaderDemo();
	}

	private static void fileReaderDemo() {
		String separator = File.separator;
		File file = new File("D:" + separator + "test" + separator + "test3.txt");
		if(file.exists()){
			FileReader in = null;
			try {
				in = new FileReader(file);
				char[] data = new char[1024];
				int length = in.read(data); //向字节数组中读取
				System.out.println(length);
				System.out.println(new String(data, 0, length));
			} catch (IOException e) {
				e.printStackTrace();
			}finally {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
